import { useEffect, useState } from 'react';
import { getUsers } from '@/api/users';
import './index.css';
import Users from '@/types/users';

const Index = () => {
  // 处理数据的类型
  const [userResponse, setUserResponse] = useState<Users.IUserList>();
  useEffect(() => {
    const loadData = async () => {
      const res = await getUsers();
      setUserResponse(res);
    };
    loadData();
  }, []);
  return (
    <div className="container-box">
      <main>
        {userResponse?.userList[0].map(user => (
          <div key={user.id}>
            <h1>{user.pickName}</h1>
          </div>
        ))}
      </main>
      <footer className="footer"></footer>
    </div>
  );
};

export default Index;
